$(function() {
  $(".nav.navbar-nav").children(":eq(2)").addClass("active").siblings(".active").removeClass("active")
  $.get(base_url + "/api/blocks", function(data) {
    $("#found-tab").children("span").text(data.maturedTotal);
    $("#unfinished-tab").children("span").text(data.immatureTotal);
    $("#new-tab").children("span").text(data.candidatesTotal);
    if (data.matured) {
      $("#matured").tmpl(data.matured, {
        isLucky: function() {
          return (this.data.shares / this.data.difficulty) <= 1
        },
        issc: function() {
          return (coinType=="SC");
        }
      }).appendTo(".matured-list");
    }
    if (data.immature) {
      $("#matured").tmpl(data.immature, {
        isLucky: function() {
          return (this.data.shares / this.data.difficulty) <= 1
        },
        issc: function() {
          return (coinType=="SC");
        }
      }).appendTo(".immatured-list");
    }
    if (data.candidates) {
      $("#newblock").tmpl(data.candidates, {
        isLucky: function() {
          return (this.data.shares / this.data.difficulty) <= 1
        }
      }).appendTo(".newblock-list");
    }
  });
  $(".block-types a").click(function() {
    $(this).addClass("active").siblings(".active").removeClass("active")
  });
});
